package com.wowudi.controller;

import com.wowudi.entity.User;
import com.wowudi.entity.dto.Result;
import com.wowudi.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@Api(tags = "用户管理")
@RequestMapping("api/system/user")
public class UserController {

    @Autowired
    private UserService userService;


    @ApiOperation(value = "用户登录")
    @PostMapping("login/{name}/{pwd}")
    public Result login(@PathVariable("name") String name, @PathVariable("pwd") String pwd){
        Result result = userService.login(name, pwd);
        return result;
    }


    @ApiOperation(value = "修改用户信息")
    @PostMapping("updateUser")
    public Result updateUser(@RequestBody User user){
        Result result = userService.updateUser(user);
        return result;
    }

    @ApiOperation(value = "查询所有用户信息")
    @GetMapping("findPageUser")
    public Result findPageUser(String userName){
        System.out.println(userName);
        Result result = userService.findPageUser(userName);
        return result;
    }


}
